package com.mantru.iotpot.Cook;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import com.mantru.iotpot.ApplicationClass;
import com.mantru.iotpot.Cleaning.CleanWayActivity;
import com.mantru.iotpot.R;
import com.mantru.iotpot.Tools.LoadingDialogUtil;

public class FinishFoodActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main9);
        findViewById(R.id.finish_back).setOnClickListener(v -> {
//            LoadingDialogUtil.showLoadingDialog(FinishFoodActivity.this);
            finish();
        });
        findViewById(R.id.finish_wash).setOnClickListener(v->{
//            LoadingDialogUtil.showLoadingDialog(FinishFoodActivity.this);
            startActivity(new Intent(this, CleanWayActivity.class));
            finish();
//            Toast.makeText(this,"此功能还在开发中",Toast.LENGTH_SHORT).show();
        });
    }

//    private BroadcastReceiver receiver = new BroadcastReceiver() {
//        @Override
//        public void onReceive(Context context, Intent intent) {
//            if ("ACTION_CLOSE_LOADING_DIALOG".equals(intent.getAction())) {
//                LoadingDialogUtil.closeLoadingDialog();
//            }
//        }
//    };

    @Override
    protected void onStart() {
        super.onStart();
//        LocalBroadcastManager.getInstance(this).registerReceiver(receiver, new IntentFilter("ACTION_CLOSE_LOADING_DIALOG"));
    }

    @Override
    protected void onStop() {
        super.onStop();
//        LocalBroadcastManager.getInstance(this).unregisterReceiver(receiver);
    }

    @Override
    protected void onResume() {
        super.onResume();
//        // 在界面渲染完成后发送广播关闭弹窗
//        new Handler().post(new Runnable() {
//            @Override
//            public void run() {
//                ((ApplicationClass) getApplication()).sendBroadcast("ACTION_CLOSE_LOADING_DIALOG");
//            }
//        });
    }
}